<?php
\Phpcmf\Hooks::app_on('quan', 'module_content_after', function($data, $old) {
    // 申请圈子之后
    if ($data[1]['status'] == 9) {
		//$data[1]['yingyong'] = $_GET['s'];
		//dr_debug('文$data', $data);
		//dr_debug('文$old', $old);
        // 9表示审核通过的
		// 插入数据
		if(MOD_DIR=='quan'){
		    
			$jiaru = \Phpcmf\Service::M()->db->table('1_quan_jiaquan')->where('quanid',$data[1]['id'])->where('uid',$data[1]['uid'])->countAllResults();
			//判断是否加入圈子
			if(!$jiaru){
				$insert_data = [
					'quanid' => $data[1]['id'],
					'uid' => $data[1]['uid'],
					'shenhe' => 1,
					'tianjiashijian' => time(),
				];
				\Phpcmf\Service::M()->db->table('1_quan_jiaquan')->insert($insert_data);
			}
			$quanqun = \Phpcmf\Service::M()->db->table('1_quanqun')->where('uid',$data[1]['uid'])->where('quanid',$data[1]['id'])->countAllResults();;
			if(!$quanqun){
			    	$insert_quanqun_data = [
				'catid' => 1,
				'title' => $data[1]['title'],
				'uid' => $data[1]['uid'],
				'quanid' => $data[1]['id'],
				'uid' => $data[1]['uid'],
				'inputip' => $data[1]['inputip'],
				'updatetime' => time(),
				'inputtime' => time(),
				'leixing' => 2,
				'yonghuid' => 0,
				'shuoming' => '',
				'fstatus' => 1,
				'guanliyuanid' => '{'.$data[1]['uid'].'}',
			];
			\Phpcmf\Service::M()->db->table('1_quanqun')->insert($insert_quanqun_data);
			$id = \Phpcmf\Service::M()->db->insertID();
			$insert_quanqun_data_0 = [
				'id' => $id,
				'uid' => $data[1]['uid'],
				'catid' => 1,
				'content' => '',
			];
			\Phpcmf\Service::M()->db->table('1_quanqun_data_0')->insert($insert_quanqun_data_0);
			}
		
		}
		
		
        
    }
});